Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update URIValueFromNodeDecoder for DeepObject. #125

Conversation

kstefanou52
Copy link
Contributor

Motivation

As discussed in [Generator] Add support of deepObject style in query params #538, there is a misimplementation of the decodeRootIfPresent method in URIValueFromNodeDecoder. When using the deepObject style, the node for rootValue is correctly empty, containing only the sub-objects.

Without this PR, the tests for Add support of deepObject style in query params #538 are failing.

Modifications

  • Updated the decodeRootIfPresent(_ type:) throws -> T method to ignore whether currentElementAsArray is empty or not.

Result

Test Plan

This PR includes unit tests that validate the change to decodeRootIfPresent(_ type:) throws -> T within Test_Converter+Server as well as in Test_serverConversionExtensions.

### Motivation

As discussed in [[Generator] Add support of deepObject style in query params #538](apple/swift-openapi-generator#538 (comment)), there is a misimplementation of the `decodeRootIfPresent` method in `URIValueFromNodeDecoder`. When using the `deepObject` style, the node for `rootValue` is correctly empty, containing only the sub-objects.

Without this PR, the tests for [Add support of deepObject style in query params #538](apple/swift-openapi-generator#538) are failing.

### Modifications

- Updated the `decodeRootIfPresent(_ type:) throws -> T` method to ignore whether `currentElementAsArray` is empty or not.

### Result

- Enables the tests in the [Generator part of the PR](apple/swift-openapi-generator#538) to pass successfully.

### Test Plan

This PR includes unit tests that validate the change to `decodeRootIfPresent(_ type:) throws -> T` within `Test_Converter+Server` as well as in `Test_serverConversionExtensions`.
@czechboy0
Copy link
Contributor

@kstefanou52 When reviewing this change I realized we'll need a few more changes here, which I'll look into doing next week. I'll let you know when they're ready.

@kstefanou52
Copy link
Contributor Author

@kstefanou52 When reviewing this change I realized we'll need a few more changes here, which I'll look into doing next week. I'll let you know when they're ready.

Sure! Let me know if you would like some help on this!

@czechboy0
Copy link
Contributor

Okay I have the new PR coming up shortly, I ended up completely refactoring URIParser to make this more maintainable and allow handling deepObject values correctly. I copied some of the test cases from your PR - thanks for those!

Once we land my PR, you should be unblocked again to finish the deepObject support in the generator repo.

@czechboy0 czechboy0 closed this Nov 13, 2024
@czechboy0
Copy link
Contributor

Ok @kstefanou52 here's my PR: #127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants